//
//  QSMySetViewController.m
//  DigitalEconomy_iOS
//
//  Created by Ding on 2020/5/25.
//  Copyright © 2020 DingC. All rights reserved.
//

#import "QSMySetViewController.h"
#import "QSUserInterface.h"
@interface QSMySetViewController ()
@property (nonatomic, strong)UIButton *logoutButton;
@end
static NSString *myInfoDefaultCell = @"MyInfoDefaultCell";

@implementation QSMySetViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"设置";
    // Do any additional setup after loading the view.
    [self configSubView];
}


- (void)configSubView{
    self.view.backgroundColor = [UIColor colorWithHexString:@"#F1F3F4"];
    self.tableView.backgroundColor = [UIColor colorWithHexString:@"#F1F3F4"];

    [self.view addSubview:self.logoutButton];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:myInfoDefaultCell];
    [_logoutButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(kRealValue(26));
        make.right.equalTo(self.view).offset(- kRealValue(26));
        make.bottom.equalTo(self.view).offset(- kRealValue(57));
        make.height.offset(kRealValue(44));
    }];
}
#pragma mark -- 懒加载
- (UIButton *)logoutButton{
    if (!_logoutButton) {
        _logoutButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_logoutButton setTitle:@"退出登录" forState:UIControlStateNormal];
        [_logoutButton setTitleColor:[UIColor QSColorWhiteFFFFFF] forState:UIControlStateNormal];
        _logoutButton.backgroundColor = [UIColor colorWithHexString:@"#128BEC"];
        _logoutButton.titleLabel.font = [UIFont QSFontOfSize16];
        _logoutButton.layer.cornerRadius = 22;
        [_logoutButton addTarget:self action:@selector(logOutAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _logoutButton;
}
#pragma mark -- TableViewDelegate & TableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return kRealValue(49);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:myInfoDefaultCell];
    if (indexPath.row == 0) {
        cell.textLabel.text = @"关于我们";
        //            cell.detailTextLabel.text = kcur.name;
    }else{
        cell.textLabel.text = @"使用帮助";
        //            cell.detailTextLabel.text = _currentUser.townshipName;
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {

    }else{
        
    }
    [QSAppKeyWindow showAutoHideHudWithText:@"内容正在准备中,敬请期待！"];
}

- (void)logOutAction:(UIButton *)sender{
    [QSUserInterface logoutWithBlock:^(ResponseMessage * _Nonnull rspStatusAndMessage, NSDictionary * _Nonnull result) {
        if (rspStatusAndMessage.code == kResponseSuccessCode) {
            NSLog(@"退出成功");
        }
    }];
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:kLoginStateKey];
    [[QSUserManager sharedQSUserManager] removeUser];
    [[QSUserManager sharedQSUserManager] turnToLoginViewController];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
